package org.jeecg.modules.health_records.health_seedoc.service.impl;

import org.jeecg.modules.health_records.health_seedoc.entity.HealthSeeDocInfo;
import org.jeecg.modules.health_records.health_seedoc.mapper.HealthSeeDocInfoMapper;
import org.jeecg.modules.health_records.health_seedoc.service.IHealthSeeDocInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 既往就诊信息(可传图片)
 * @Author: jeecg-boot
 * @Date:   2025-07-04
 * @Version: V1.0
 */
@Service
public class HealthSeeDocInfoServiceImpl extends ServiceImpl<HealthSeeDocInfoMapper, HealthSeeDocInfo> implements IHealthSeeDocInfoService {

    @Autowired
    private HealthSeeDocInfoMapper healthSeeDocInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSeeDocInfo> queryByRecordId(HealthSeeDocInfo healthSeeDocInfo) {
        return healthSeeDocInfoMapper.queryByRecordId(Long.valueOf(healthSeeDocInfo.getRecordid()), healthSeeDocInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSeeDocInfo> queryElecRecord(HealthSeeDocInfo healthSeeDocInfo) {
        return healthSeeDocInfoMapper.queryElecRecord(Long.valueOf(healthSeeDocInfo.getRecordid()), healthSeeDocInfo.getIdNumber());

    }

    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSeeDocInfo> newQueryElecRecord(HealthSeeDocInfo healthSeeDocInfo) {
        return healthSeeDocInfoMapper.newQueryElecRecord(Long.valueOf(healthSeeDocInfo.getRecordid()),healthSeeDocInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSeeDocInfo> newQueryPastRecord(HealthSeeDocInfo healthSeeDocInfo) {
        return healthSeeDocInfoMapper.newQueryPastRecord(Long.valueOf(healthSeeDocInfo.getRecordid()),healthSeeDocInfo.getIdNumber());

    }
    
}
